<html>
<head><meta charset="utf-8"><title>Syntax Musing: `try as Something { ... }` · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html">Syntax Musing: `try as Something { ... }`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209194585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209194585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209194585">(Sep 05 2020 at 20:27)</a>:</h4>
<p>I was reading and pondering past <code>try</code> &amp; <code>Try</code> conversations, and this post caught my eye particularly: <a href="https://github.com/rust-lang/rust/issues/70941#issuecomment-612167041">https://github.com/rust-lang/rust/issues/70941#issuecomment-612167041</a></p>
<p>I'd previously pondered <code>try: Whatever{}</code> and <code>try -&gt; Whatever {}</code>, but neither of them really excited me.  The former seems like <code>try{}:Whatever</code> and thus feels like <code>try{}</code> and <code>try:_{}</code> should be the same.  The latter seems like it'd imply a decision for <code>try fn foo() -&gt; Whatever</code> that I think we all want to sidestep for now.</p>
<p>But <code>try as Whatever {}</code> is interesting to me because <code>$expr</code> and <code>$expr as _</code> already have different consequences in a way that <code>$expr: _</code> doesn't.  (I'm particularly thinking about how <code>Box::new(x)</code> sometimes ends up needing to be <code>Box::new(x) as _</code> to get the correct type inferred when it's in a context that's trying to coerce to a box-of-unsized.)</p>
<p>We could then say that <code>?</code>-in-<code>try{}</code> <strong>does not</strong> do error conversion, but that you can opt into the conversion with <code>as</code>.  That would allow us to refactor <code>Try</code> to mean that a basic <code>try { (a?, b?) }</code> wouldn't need annotations if anywhere if <code>a</code> and <code>b</code> were both <code>Result&lt;_, SameError&gt;</code> or both <code>Option&lt;_&gt;</code>.  It wouldn't work if they were different, but that seems reasonable as then you'd need to specify the type to which they should both convert _somewhere_ anyway, and you could do that with <code>as</code> -- even just with <code>try as _ { (a?, b?) }</code> if it's clear from context, such as the return type.</p>
<p>For a concrete example that this could be useful, I think both these try blocks wouldn't need the type annotation any more, nor an <code>as</code>: <a href="https://github.com/rust-lang/rust/blob/04f44fb9232dc960d213d0df4a203c387215a5ff/compiler/rustc_mir/src/borrow_check/nll.rs#L352-L364">https://github.com/rust-lang/rust/blob/04f44fb9232dc960d213d0df4a203c387215a5ff/compiler/rustc_mir/src/borrow_check/nll.rs#L352-L364</a> .  Ditto for these three conceptual-<code>try</code>-<code>catch</code>es: <a href="https://github.com/rust-lang/rust/blob/04f44fb9232dc960d213d0df4a203c387215a5ff/compiler/rustc_codegen_ssa/src/back/linker.rs#L532-L576">https://github.com/rust-lang/rust/blob/04f44fb9232dc960d213d0df4a203c387215a5ff/compiler/rustc_codegen_ssa/src/back/linker.rs#L532-L576</a></p>
<p>(And since <code>try{}</code> blocks aren't stable, "removing" the conversion from <code>?</code> there can't break anyone like it would if we tried to do it everywhere.  It just tweaks the mental model of what's responsible for the conversion a bit.)</p>
<p>Thoughts?</p>



<a name="209195042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195042">(Sep 05 2020 at 20:40)</a>:</h4>
<p>+1</p>



<a name="209195340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195340">(Sep 05 2020 at 20:46)</a>:</h4>
<p>oo Interesting</p>



<a name="209195352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195352">(Sep 05 2020 at 20:46)</a>:</h4>
<p>no type inference by default sounds nice</p>



<a name="209195366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195366">(Sep 05 2020 at 20:47)</a>:</h4>
<p>Another thought: this could help some cases with closures as well -- <code>|| { Ok(a? + b?) }</code> often doesn't work (unknown target error type), but <code>|| try { a? + b? }</code> _would_ work if the two variables already have the same error type.</p>
<p>(So in a way this is the "add a fallback in inference to use the identity <code>From::from</code> impl", but done with syntax instead of trying to do it in the type system)</p>



<a name="209195372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195372">(Sep 05 2020 at 20:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60/near/209195366">said</a>:</p>
<blockquote>
<p>Another thought: this could help some cases with closures as well -- <code>|| { Ok(a? + b?) }</code> doesn't work (unknown target error type), but <code>|| try { a? + b? }</code> _would_ work if the two variables already have the same error type.</p>
<p>(So in a way this is the "add a fallback in inference to use the identity <code>From::from</code> impl", but done with syntax instead of trying to do it in the type system)</p>
</blockquote>
<p>I would be <em>very</em> interested in this</p>



<a name="209195376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195376">(Sep 05 2020 at 20:47)</a>:</h4>
<p>as normally can apply coersions right?</p>



<a name="209195381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195381">(Sep 05 2020 at 20:47)</a>:</h4>
<p><a href="https://gitlab.com/YottaDB/Lang/YDBRust/-/issues/35#note_405685772">https://gitlab.com/YottaDB/Lang/YDBRust/-/issues/35#note_405685772</a></p>



<a name="209195425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195425">(Sep 05 2020 at 20:48)</a>:</h4>
<p>this feels slightly different</p>



<a name="209195441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195441">(Sep 05 2020 at 20:49)</a>:</h4>
<p>Yes, <code>as</code> will do coercions as well as casts.</p>



<a name="209195976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195976">(Sep 05 2020 at 21:04)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> I'm not sure I'm following the issue you're hitting here -- what I mention here wouldn't change that <code>From</code> is how result-errors get converted, just move around where it's happening (and where that detail is specified).  So if the trouble you're hitting is that you need multiple <code>From</code>s, this change wouldn't help you.</p>
<p>(In the design meeting a while back we talked about possibly trying to restrict conversions in different ways, but the existing stable interconversions make any meaningful tweaks there quite difficult.)</p>



<a name="209195983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195983">(Sep 05 2020 at 21:04)</a>:</h4>
<p>the trouble I'm hitting is that I need <em>no</em> Froms</p>



<a name="209195994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209195994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209195994">(Sep 05 2020 at 21:05)</a>:</h4>
<p>and <code>?</code> adds an intermediate type rust doesn't know how to infer</p>



<a name="209196013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209196013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209196013">(Sep 05 2020 at 21:05)</a>:</h4>
<p>the thing about specialization is just me trying to work around that</p>



<a name="209196079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209196079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209196079">(Sep 05 2020 at 21:06)</a>:</h4>
<p>actually I guess that would still end up with <code>YDBError</code> in the user variant of the enum ... so never mind, ignore me</p>



<a name="209197958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209197958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209197958">(Sep 05 2020 at 22:13)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> So, in this model, <code>try { foo()?; bar()?; ... }</code> won't work if foo and bar return different error types, but <code>try as _ { foo()?; bar()?; ... }</code> would?</p>



<a name="209197969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209197969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209197969">(Sep 05 2020 at 22:13)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> Exactly.  (Well, assuming there was enough context to infer the <code>_</code>.)</p>



<a name="209198008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198008">(Sep 05 2020 at 22:14)</a>:</h4>
<p>That feels like it's kinda the reverse of what I usually want.</p>



<a name="209198032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198032">(Sep 05 2020 at 22:15)</a>:</h4>
<p>I <em>do</em> typically need <code>?</code> to do type inference, and then I'd like <code>try</code> to attempt to know what type to convert to so I don't have the double-Into problem.</p>



<a name="209198036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198036">(Sep 05 2020 at 22:15)</a>:</h4>
<p>The inference that causes problems isn't the one between <code>try</code> and <code>?</code>, it's the one between <code>try</code> and the return type of the current function.</p>



<a name="209198074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198074">(Sep 05 2020 at 22:16)</a>:</h4>
<p>That's the one I'd like to opt out of if possible, but I don't know if that's reasonably possible.</p>



<a name="209198087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198087">(Sep 05 2020 at 22:16)</a>:</h4>
<p>I almost feel like there should be a shorthand for "<code>?</code> but don't do error conversion, just return the error as-is please".</p>



<a name="209198143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198143">(Sep 05 2020 at 22:18)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> Still a thought-provoking idea, though. Still thinking about it.</p>



<a name="209198216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198216">(Sep 05 2020 at 22:21)</a>:</h4>
<p>So if I understand what you want, it's what would be <code>fn foo() -&gt; ... { try {  let x = try as _ { ... }; x? } }</code> in this model?  Because it's the <code>?</code> on the result of the <code>try</code> that's causing you issues?</p>



<a name="209198256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198256">(Sep 05 2020 at 22:22)</a>:</h4>
<p>/me stares at that and tries to interpret.</p>



<a name="209198260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198260">(Sep 05 2020 at 22:22)</a>:</h4>
<p>Sorry, you want the error conversion inside but not outside.</p>



<a name="209198266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198266">(Sep 05 2020 at 22:22)</a>:</h4>
<p>Yeah, I think that <em>does</em> express what I mean.</p>



<a name="209198271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198271">(Sep 05 2020 at 22:23)</a>:</h4>
<p>Convert the error types inside the inner try, then use the same error type in the outer try as the function.</p>



<a name="209198273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198273">(Sep 05 2020 at 22:23)</a>:</h4>
<p>(I half-wish we'd just said "no <code>?</code> unless you're in a <code>try</code>" like we have "no <code>.await</code> except in an <code>async</code>", but that'd be way too much churn now.)</p>



<a name="209198281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198281">(Sep 05 2020 at 22:23)</a>:</h4>
<p>(I also think that'd be painful in practice.)</p>



<a name="209198324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198324">(Sep 05 2020 at 22:24)</a>:</h4>
<p>Obviously that wouldn't be a very appealing pattern in general, since it involves multiple levels of <code>try</code> to express one, but it's an accurate description of the behavior I'd like to have somehow, yes.</p>



<a name="209198325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198325">(Sep 05 2020 at 22:24)</a>:</h4>
<p>(It'd probably require <code>try fn</code> to not be completely horrible, like <code>.await</code> would be painful without <code>async fn</code>.)</p>



<a name="209198333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198333">(Sep 05 2020 at 22:25)</a>:</h4>
<p>It'd also require <code>try fn</code> to not do inference, which I think would be painful in common usage when there <em>isn't</em> an inner try block.</p>



<a name="209198379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198379">(Sep 05 2020 at 22:26)</a>:</h4>
<p>Conversation topic: We could do an edition change to remove error-conversion from <code>?</code> and have the opt-in for it be to use a <code>try</code>.</p>



<a name="209198382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198382">(Sep 05 2020 at 22:26)</a>:</h4>
<p>I was thinking about `baz()? else |error| { ... } yesterday in relation to the Try impl for Ordering</p>



<a name="209198390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198390">(Sep 05 2020 at 22:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60/near/209198379">said</a>:</p>
<blockquote>
<p>Conversation topic: We could do an edition change to remove error-conversion from <code>?</code> and have the opt-in for it be to use a <code>try</code>.</p>
</blockquote>
<p>I think the same problem applies there. If you're <em>not</em> using a try, you usually <em>do</em> want error conversion, I think.</p>



<a name="209198394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198394">(Sep 05 2020 at 22:27)</a>:</h4>
<p><code>fn main() -&gt; anyhow::Result&lt;()&gt; { may_fail()?; may_fail_differently()?; Ok(()) }</code> is a common occurrence for me.</p>



<a name="209198407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198407">(Sep 05 2020 at 22:27)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> Have a github link to some code where you're doing the "convert inside the try but not outside it" semantic?  The <code>try</code>s I found in the compiler were all "everything in here is <code>io::Result</code>".</p>



<a name="209198454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198454">(Sep 05 2020 at 22:28)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> I don't have any code using <code>try</code>, since it isn't stable. Every time the pattern would come up, I end up working around it.</p>



<a name="209198457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198457">(Sep 05 2020 at 22:28)</a>:</h4>
<p>/me tries to think of an example.</p>



<a name="209198467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198467">(Sep 05 2020 at 22:29)</a>:</h4>
<p>(A conceptual try where the code is actually combinators or matches is fine -- I wasn't expecting a literal <code>try</code> in your code, but it's hard to search for conceptual try :P)</p>



<a name="209198480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198480">(Sep 05 2020 at 22:29)</a>:</h4>
<p>(Exactly; that's what's making it a challenge, because I don't have a mental index for "places I wished I had try".)</p>



<a name="209198609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198609">(Sep 05 2020 at 22:33)</a>:</h4>
<p>Roughly speaking, one common pattern tends to be "try doing some things that might fail; if they fail, on the way out I'd like to do XYZ cleanup akin to a <code>finally</code> block and then return the error, but I don't want to go write a bespoke RAII type".</p>



<a name="209198660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198660">(Sep 05 2020 at 22:35)</a>:</h4>
<p>I wanted try not to long ago so I could instrument all errors produced by a scope in a test after a cmd runner had been setup with context from that runner should an error happen</p>



<a name="209198663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198663">(Sep 05 2020 at 22:35)</a>:</h4>
<p>but try doesn't really solve that problem for me completely because I can't apply that same context to panics produced inside that scope</p>



<a name="209198664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198664">(Sep 05 2020 at 22:35)</a>:</h4>
<p>Oooh, right, that's another good one. <code>try { ... }.with_context(|| format!(...))?</code>.</p>



<a name="209198706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198706">(Sep 05 2020 at 22:36)</a>:</h4>
<p>so I've been trying to think of some sort of thread local thing that is accessed by a custom panic hook to grab in scope context</p>



<a name="209198707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198707">(Sep 05 2020 at 22:36)</a>:</h4>
<p>To avoid putting the <code>with_context</code> on all the <code>?</code>s individually, Josh?</p>



<a name="209198709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198709">(Sep 05 2020 at 22:36)</a>:</h4>
<p>Yes, exactly.</p>



<a name="209198762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198762">(Sep 05 2020 at 22:38)</a>:</h4>
<p>Hmm, that one's probably particularly awkward because method calls block inference today</p>



<a name="209198770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198770">(Sep 05 2020 at 22:39)</a>:</h4>
<p>Yeah, it'd be lovely if I didn't have to write <code>anyhow::Result&lt;...&gt;</code> there more than once.</p>



<a name="209198771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198771">(Sep 05 2020 at 22:39)</a>:</h4>
<p>(I already have to write it in the function's return type.)</p>



<a name="209198814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198814">(Sep 05 2020 at 22:40)</a>:</h4>
<p>this function</p>



<a name="209198815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198815">(Sep 05 2020 at 22:40)</a>:</h4>
<p><a href="https://github.com/ZcashFoundation/zebra/blob/main/zebra-test/src/command.rs#L270">https://github.com/ZcashFoundation/zebra/blob/main/zebra-test/src/command.rs#L270</a></p>



<a name="209198818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198818">(Sep 05 2020 at 22:40)</a>:</h4>
<p>used here <a href="https://github.com/ZcashFoundation/zebra/blob/main/zebra-test/src/command.rs#L209">https://github.com/ZcashFoundation/zebra/blob/main/zebra-test/src/command.rs#L209</a></p>



<a name="209198824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198824">(Sep 05 2020 at 22:41)</a>:</h4>
<p><span class="user-mention" data-user-id="220273">@Jane Lusby</span> In the latter file, those function names and comments are confusing me, and I feel like I must be reading them wrong.</p>



<a name="209198863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198863">(Sep 05 2020 at 22:42)</a>:</h4>
<p>and here <a href="https://github.com/ZcashFoundation/zebra/blob/main/zebrad/tests/acceptance.rs#L79">https://github.com/ZcashFoundation/zebra/blob/main/zebrad/tests/acceptance.rs#L79</a></p>



<a name="209198864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198864">(Sep 05 2020 at 22:42)</a>:</h4>
<p><code>assert_was_killed</code> returns an error if <code>self.was_killed()</code>, and Ok otherwise, but the comment seems to say the reverse.</p>



<a name="209198865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198865">(Sep 05 2020 at 22:42)</a>:</h4>
<p>And vice versa for <code>assert_was_not_killed()</code>.</p>



<a name="209198866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198866">(Sep 05 2020 at 22:42)</a>:</h4>
<p>that might be backwards</p>



<a name="209198872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198872">(Sep 05 2020 at 22:43)</a>:</h4>
<p>I think our was_killed might also be backwards</p>



<a name="209198876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198876">(Sep 05 2020 at 22:43)</a>:</h4>
<p>so it's cancelling eachother out</p>



<a name="209198877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198877">(Sep 05 2020 at 22:43)</a>:</h4>
<p>lol</p>



<a name="209198878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198878">(Sep 05 2020 at 22:43)</a>:</h4>
<p>Either one of those two explanations would make sense, thank you. :)</p>



<a name="209198879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198879">(Sep 05 2020 at 22:43)</a>:</h4>
<p>don't read the logic, just the error handling!</p>



<a name="209198880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198880">(Sep 05 2020 at 22:43)</a>:</h4>
<p>ll</p>



<a name="209198881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198881">(Sep 05 2020 at 22:43)</a>:</h4>
<p>lol*</p>



<a name="209198921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198921">(Sep 05 2020 at 22:44)</a>:</h4>
<p>AFAICT unless <code>with_context</code> becomes a trait call, that just can't work today -- if inference is supposed to be producing the <code>impl Try</code> type out of what's happening inside it, the compiler will stop and give up when it sees the method call.</p>



<a name="209198934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198934">(Sep 05 2020 at 22:45)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> It's a trait method on a sealed trait that's implemented only for <code>Result&lt;T, anyhow::Error&gt;</code>.</p>



<a name="209198983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198983">(Sep 05 2020 at 22:47)</a>:</h4>
<p>Well, we're at the limit of my understanding of how inference works then -- I don't know if it needs to be on <code>Try</code> for it to be understood here.</p>



<a name="209198987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209198987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209198987">(Sep 05 2020 at 22:47)</a>:</h4>
<p>I could live with that case not working.</p>



<a name="209199024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199024">(Sep 05 2020 at 22:48)</a>:</h4>
<p>I think I'd be more interested in having this work:</p>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">..</span><span class="p">.</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="n">cleanup</span><span class="p">();</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="o">?</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="209199036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199036">(Sep 05 2020 at 22:49)</a>:</h4>
<p>If the compiler does realize it's that, though, then <code>try as _ { }.with_context()?</code> would pick up the anyhow-ness from the <code>with_context</code>, though -- which would meet the "don't want to type it twice" goal.  (If perhaps be non-ideal in requiring the <code>as _</code> typing.)</p>



<a name="209199037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199037">(Sep 05 2020 at 22:49)</a>:</h4>
<p>I think that's a rough approximation of around half the cases I want <code>try</code>.</p>



<a name="209199042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199042">(Sep 05 2020 at 22:49)</a>:</h4>
<p>So cleanup that runs so long as it doesn't <code>panic</code>?</p>



<a name="209199086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199086">(Sep 05 2020 at 22:50)</a>:</h4>
<p>Generally local cleanup, not "before the program ends" cleanup, yes.</p>



<a name="209199132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199132">(Sep 05 2020 at 22:52)</a>:</h4>
<p>I'm just poking at the difference between it and</p>
<div class="codehilite"><pre><span></span><code><span class="n">scopeguard</span><span class="o">!</span><span class="p">(</span><span class="n">cleanup</span><span class="p">());</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">..?</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="209199134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199134">(Sep 05 2020 at 22:52)</a>:</h4>
<p>(borrow difference, perhaps?)</p>



<a name="209199135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199135">(Sep 05 2020 at 22:52)</a>:</h4>
<p>The difference is that I haven't seen a generic implementation of <code>scopeguard!</code> before? ;)</p>



<a name="209199144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199144">(Sep 05 2020 at 22:53)</a>:</h4>
<p>Also, sometimes I don't want to call the cleanup unless the block failed; if it succeeded I want to do something different.</p>



<a name="209199177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199177">(Sep 05 2020 at 22:54)</a>:</h4>
<p>I've never used one, just sorta assumed it <a href="https://lib.rs/crates/scopeguard">exists</a> :P</p>



<a name="209199190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199190">(Sep 05 2020 at 22:55)</a>:</h4>
<p>Interesting.</p>



<a name="209199192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199192">(Sep 05 2020 at 22:55)</a>:</h4>
<p>That might well work for some cases I want.</p>



<a name="209199231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199231">(Sep 05 2020 at 22:56)</a>:</h4>
<p>Wouldn't help with the "only on <code>Err</code> with a specific error, not on <code>Ok</code> or other <code>Err</code>" case, but it'd help in other cases.</p>



<a name="209199232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199232">(Sep 05 2020 at 22:56)</a>:</h4>
<p>But I guess the meta-question is the best way to enable/disable conversion in <code>?</code></p>



<a name="209199237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199237">(Sep 05 2020 at 22:56)</a>:</h4>
<p>True. And whether we can do that in a backwards-compatible way.</p>



<a name="209199251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199251">(Sep 05 2020 at 22:57)</a>:</h4>
<p>Hypothetical (horrible syntax, just a straw idea): <code>?</code> does conversions, <code>?=</code> doesn't.</p>



<a name="209199252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199252">(Sep 05 2020 at 22:57)</a>:</h4>
<p>I think I ended up where I did with an implicit assumption that <code>try</code> seems like the only place to put it.</p>



<a name="209199290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199290">(Sep 05 2020 at 22:58)</a>:</h4>
<p>Yeah, I just couldn't think of anything non-horrible, since so much of the fun of <code>?</code> is that it's short-and-sweet</p>



<a name="209199293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199293">(Sep 05 2020 at 22:58)</a>:</h4>
<p>Yup.</p>



<a name="209199308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199308">(Sep 05 2020 at 22:59)</a>:</h4>
<p>Another possibility would be to do some kind of "smart inference", where the compiler has enough information to know that something has been through two <code>?</code> conversions, so it should further constrain the "middle" type to be either the initial or final type.</p>



<a name="209199351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199351">(Sep 05 2020 at 23:00)</a>:</h4>
<p>I guess method-like opt-in/out would be possible -- <code>.bikeshed()?</code></p>



<a name="209199364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199364">(Sep 05 2020 at 23:01)</a>:</h4>
<p>That might reduce to "there's another Result-like type that doesn't error-convert"</p>



<a name="209199460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199460">(Sep 05 2020 at 23:04)</a>:</h4>
<p>Huh.</p>



<a name="209199461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199461">(Sep 05 2020 at 23:04)</a>:</h4>
<p>That seems feasible.</p>



<a name="209199463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199463">(Sep 05 2020 at 23:04)</a>:</h4>
<p>Also, if only we had GATs and could get <code>Result</code> back without needing to use "there's only on implementation of the trait for that type" or "we infer it from the context"...</p>



<a name="209199479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199479">(Sep 05 2020 at 23:05)</a>:</h4>
<p>Without exposing it outside of <code>std</code>, would specialization allow us to have a special <code>VerbatimWrapped</code> type that wraps a result such that <code>?</code> can only return that wrapped type?</p>



<a name="209199480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199480">(Sep 05 2020 at 23:05)</a>:</h4>
<p>(Of course, at that point <code>Try</code> is even more just monads.)</p>



<a name="209199523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199523">(Sep 05 2020 at 23:06)</a>:</h4>
<p><code>.verbatim()?</code> where <code>fn verbatim&lt;T&gt;(t: T) -&gt; VerbatimWrapped&lt;T&gt;</code> and <code>VerbatimWrapped&lt;T&gt;</code> always becomes <code>T</code> when passed through <code>?</code>.</p>



<a name="209199532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199532">(Sep 05 2020 at 23:07)</a>:</h4>
<p>Hmm, this is going to take some more context...</p>



<a name="209199535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199535">(Sep 05 2020 at 23:07)</a>:</h4>
<p>I was extending your method-like opt-out idea.</p>



<a name="209199536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199536">(Sep 05 2020 at 23:07)</a>:</h4>
<p>(from me, sorry)</p>



<a name="209199539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199539">(Sep 05 2020 at 23:07)</a>:</h4>
<p>Ah, got it.</p>



<a name="209199580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199580">(Sep 05 2020 at 23:08)</a>:</h4>
<p>I'm been thinking of changing <code>Try</code> from something that splits <code>Result&lt;T, E&gt;</code> into <code>T</code> or <code>Result&lt;!, E&gt;</code> instead of <code>T</code> or <code>E</code>.</p>



<a name="209199582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199582">(Sep 05 2020 at 23:08)</a>:</h4>
<p>That's fascinating. Do tell.</p>



<a name="209199589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199589">(Sep 05 2020 at 23:09)</a>:</h4>
<p>Because that allow us to keep the "resultness" of the error</p>



<a name="209199591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199591">(Sep 05 2020 at 23:09)</a>:</h4>
<p><em>Ah</em>.</p>



<a name="209199598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199598">(Sep 05 2020 at 23:09)</a>:</h4>
<p>So, then, <code>Try</code> on <code>Option&lt;T&gt;</code> would split it into <code>T</code> or <code>Option&lt;!&gt;</code>?</p>



<a name="209199601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199601">(Sep 05 2020 at 23:09)</a>:</h4>
<p>Yup.</p>



<a name="209199644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199644">(Sep 05 2020 at 23:10)</a>:</h4>
<p>And using <code>!</code> for this is convenient in that error conversion wouldn't need to handle the <code>Ok</code> part</p>



<a name="209199649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199649">(Sep 05 2020 at 23:10)</a>:</h4>
<p>Without forcing people to make a bunch of newtypes.</p>



<a name="209199651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199651">(Sep 05 2020 at 23:10)</a>:</h4>
<p><code>Option&lt;!&gt;</code> is a fun way to say "None". :)</p>



<a name="209199655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199655">(Sep 05 2020 at 23:10)</a>:</h4>
<p>It's effectively a type-level value.</p>



<a name="209199656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199656">(Sep 05 2020 at 23:10)</a>:</h4>
<p>(<code>Infallible</code> would be fine too -- it's not blocked on literally <code>!</code>)</p>



<a name="209199659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199659">(Sep 05 2020 at 23:10)</a>:</h4>
<p>(Of course.)</p>



<a name="209199667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199667">(Sep 05 2020 at 23:11)</a>:</h4>
<p>So, this would keep the "shape" of the result.</p>



<a name="209199672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199672">(Sep 05 2020 at 23:11)</a>:</h4>
<p>But this would mean that producing the full <code>impl Try</code> type again in <code>?</code> would know of the "result-ness"</p>



<a name="209199673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199673">(Sep 05 2020 at 23:11)</a>:</h4>
<p>Yup.</p>



<a name="209199676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199676">(Sep 05 2020 at 23:11)</a>:</h4>
<p>So we could use that to encourage it back to just being a Result again, rather that something more broad.</p>



<a name="209199677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199677">(Sep 05 2020 at 23:12)</a>:</h4>
<p>And then, the automatic conversion just has to take the "shape" <code>Result&lt;!, E&gt;</code>, convert the <code>E</code>, and let the <code>!</code> become whatever the return type is because that path can't be taken.</p>



<a name="209199722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199722">(Sep 05 2020 at 23:12)</a>:</h4>
<p>Which might not work perfectly, given that we have to support currently-stable interconversions, but if we did have a <code>.verbatim()?</code> that could turn it into a type internally that doesn't do those extra conversions</p>



<a name="209199729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199729">(Sep 05 2020 at 23:13)</a>:</h4>
<p>So we could give the implementer of <code>Try</code> control over how much inference can happen?</p>



<a name="209199734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199734">(Sep 05 2020 at 23:13)</a>:</h4>
<p>/me is fascinated.</p>



<a name="209199737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199737">(Sep 05 2020 at 23:13)</a>:</h4>
<p>Yup, and the <code>!</code> avoids the unfortunate phantom(-ish) type parameters on the impls that were necessary in one of the other designs, where you ended up with <code>impl&lt;T, U, E, F&gt;</code> because you had to handle the oks changing too.</p>



<a name="209199779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199779">(Sep 05 2020 at 23:14)</a>:</h4>
<p>In fact, you almost don't need some of the type parameters on <code>Try</code>, you only need them on the specific function.</p>



<a name="209199797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199797">(Sep 05 2020 at 23:15)</a>:</h4>
<p>Splitting up the trait may also allow things like <code>Result&lt;T, !&gt;?</code> in a <code>-&gt; ()</code> method, while not allowing <code>()??????????</code>.</p>



<a name="209199846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199846">(Sep 05 2020 at 23:16)</a>:</h4>
<p>I just don't know if this all will end up needing GATs or not</p>



<a name="209199848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199848">(Sep 05 2020 at 23:16)</a>:</h4>
<p>I would <em>love</em> to see this working.</p>



<a name="209199862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199862">(Sep 05 2020 at 23:18)</a>:</h4>
<p>(If you hadn't guessed, this playing with <code>Result&lt;!, E&gt;</code> is also the source of my other topic here about <code>feature(exhaustive_patterns)</code>.)</p>



<a name="209199908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199908">(Sep 05 2020 at 23:18)</a>:</h4>
<p>The one where you can <code>match that_type { Err(e) =&gt; ... }</code> without an <code>Ok</code> branch?</p>



<a name="209199911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199911">(Sep 05 2020 at 23:19)</a>:</h4>
<p>Yup.</p>



<a name="209199958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199958">(Sep 05 2020 at 23:20)</a>:</h4>
<p>Not a blocker, though -- the code being a bit less nice is ok (<code>Ok(v) =&gt; match v {}</code> works on stable with <code>Infallible</code>) since the most important part to me is the model in the type being right.</p>



<a name="209199974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209199974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209199974">(Sep 05 2020 at 23:21)</a>:</h4>
<p>So, issue 1 will be making this work without breaking existing code (possibly involving an edition boundary), and issue 2 will be making the <code>Try</code> trait work without new compiler features?</p>



<a name="209200035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200035">(Sep 05 2020 at 23:23)</a>:</h4>
<p>I think (1) shouldn't actually too bad.</p>
<p>As a sketch, maybe you have <code>impl&lt;T, E, F: From&lt;E&gt;&gt; FromErrorCarrier&lt;Result&lt;!, E&gt;&gt; for Result&lt;T, F&gt; { ... code that calls From::from ... }</code></p>



<a name="209200080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200080">(Sep 05 2020 at 23:24)</a>:</h4>
<p>which would also allow <code>impl FromErrorCarrier&lt;Result&lt;!, !&gt;&gt; for ()</code> as mentioned earlier.</p>



<a name="209200133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200133">(Sep 05 2020 at 23:26)</a>:</h4>
<p>The hard part is whether inference will flow in the correct direction and trying not to make it fragile (like <code>AsRef</code>) in the face of people adding new interconversions to their own types.</p>



<a name="209200150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200150">(Sep 05 2020 at 23:27)</a>:</h4>
<p>Right. Because <code>Try</code> and the desugar of <code>?</code> isn't stable, but it's guaranteed to use <code>Into</code> and <code>From</code> impls if you provide them?</p>



<a name="209200205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200205">(Sep 05 2020 at 23:29)</a>:</h4>
<p>The design meeting brought up a bunch of these -- Taylor pointed out a bunch of stable poll ones, and people are unfortunately even using option-to-result conversion in a few places even though we tried to keep the type unstable to prevent that.</p>



<a name="209200210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200210">(Sep 05 2020 at 23:29)</a>:</h4>
<p>Sigh.</p>



<a name="209200211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200211">(Sep 05 2020 at 23:29)</a>:</h4>
<p>Right.</p>



<a name="209200214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200214">(Sep 05 2020 at 23:29)</a>:</h4>
<p>And right, the Result one in particular needs to go through <code>From</code>.</p>



<a name="209200263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200263">(Sep 05 2020 at 23:30)</a>:</h4>
<p>With the benefit of hindsight: this is a good example that it can be a bad idea to do the "stable interface to unstable desugaring" thing, because people will find ways to rely on the desugaring.</p>



<a name="209200269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200269">(Sep 05 2020 at 23:30)</a>:</h4>
<p>/me wishes that we'd just never stabilized the ability to use <code>?</code> on anything but <code>Result</code> until we had <code>Try</code> ready to stabilize.</p>



<a name="209200298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200298">(Sep 05 2020 at 23:31)</a>:</h4>
<p>Yeah, another thing for the time machine list.</p>



<a name="209200340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200340">(Sep 05 2020 at 23:32)</a>:</h4>
<p>In theory, we <em>could</em> change that over an edition, but that'd be disruptive.</p>



<a name="209200351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200351">(Sep 05 2020 at 23:33)</a>:</h4>
<p>Actually, we might be able to arrange an edition break here.</p>



<a name="209200355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200355">(Sep 05 2020 at 23:33)</a>:</h4>
<p>Given the modified carrier mechanism you're describing, though, we might theoretically be able to make the old behavior available as <code>.foo()?</code>...</p>



<a name="209200359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200359">(Sep 05 2020 at 23:33)</a>:</h4>
<p>We can use a different trait in different editions to desugar <code>?</code></p>



<a name="209200361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200361">(Sep 05 2020 at 23:33)</a>:</h4>
<p>Right, that's what I mean.</p>



<a name="209200366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200366">(Sep 05 2020 at 23:33)</a>:</h4>
<p>That's what I was saying would be disruptive.</p>



<a name="209200375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200375">(Sep 05 2020 at 23:34)</a>:</h4>
<p>I think _just_ breaking the unintended interconversions might not be too bad.</p>



<a name="209200412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200412">(Sep 05 2020 at 23:34)</a>:</h4>
<p>Insofar as if you're relying on <code>?</code> to work with some of the more unusual cases that came up in that design meeting, you might experience breakage across the edition.</p>



<a name="209200416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200416">(Sep 05 2020 at 23:34)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> What would that look like? What would that break?</p>



<a name="209200426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200426">(Sep 05 2020 at 23:34)</a>:</h4>
<p><code>option?</code> in <code>Result&lt;_, Box&lt;SomethingThatConvertsFromImplDebug&gt;&gt;</code>, I think.</p>



<a name="209200435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200435">(Sep 05 2020 at 23:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60/near/209200340">said</a>:</p>
<blockquote>
<p>In theory, we <em>could</em> change that over an edition, but that'd be disruptive.</p>
</blockquote>
<p>slightly offtopic, but isn't that a breaking change? what can be changed in an edition and what can't?</p>



<a name="209200440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200440">(Sep 05 2020 at 23:35)</a>:</h4>
<p>A bunch of the <code>Poll</code> ones are intentional, so I don't think we'd break those.  Just the ones that weren't supposed to work but did anyway.</p>



<a name="209200479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200479">(Sep 05 2020 at 23:36)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> An edition is opt-in (via <code>edition = "..."</code> in <code>Cargo.toml</code> or equivalent rustc options), which means it <em>can</em> make breaking changes.</p>



<a name="209200481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200481">(Sep 05 2020 at 23:36)</a>:</h4>
<p>e.g. in <a href="https://github.com/rust-lang/rfcs/issues/2848#issuecomment-573472728">https://github.com/rust-lang/rfcs/issues/2848#issuecomment-573472728</a> someone said removing a trait impl was breaking and couldn't be done even in an edition</p>



<a name="209200483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200483">(Sep 05 2020 at 23:36)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> Both traits would exist and have impls in both editions.  The change would be how <code>?</code> desugars to one or the other.  (The library can't change between editions, but the frontend can.)</p>



<a name="209200495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200495">(Sep 05 2020 at 23:37)</a>:</h4>
<p>oh I see, you can change the <em>compiler</em> but not the <em>library</em></p>



<a name="209200497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200497">(Sep 05 2020 at 23:37)</a>:</h4>
<p>ok that makes sense</p>



<a name="209200543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200543">(Sep 05 2020 at 23:39)</a>:</h4>
<p>Right. We can change what things desugar to, but all the variations must be available in the library.</p>



<a name="209200549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200549">(Sep 05 2020 at 23:39)</a>:</h4>
<p>There's some discussion about how we might be able to change the implicit prelude that the compiler adds, and in that case, both preludes would exist and what'd vary by edition would be which prelude the compiler uses.</p>



<a name="209200551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200551">(Sep 05 2020 at 23:39)</a>:</h4>
<p>My usual example: We can't make <code>Range</code> not be an iterator, but we could change <code>..</code> to give a different type that's only <code>IntoIterator</code>, not <code>Iterator</code> itself.</p>



<a name="209200594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200594">(Sep 05 2020 at 23:40)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> You can even have a macro from one edition expanded in code in the other edition, and the compiler decides how to desugar things based on the edition of the span.</p>



<a name="209200597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200597">(Sep 05 2020 at 23:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60/near/209200594">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> You can even have a macro from one edition expanded in code in the other edition, and the compiler decides how to desugar things based on the edition of the span.</p>
</blockquote>
<p>wow, that's cool! Is that why <code>panic!</code> is a macro?</p>



<a name="209200602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200602">(Sep 05 2020 at 23:40)</a>:</h4>
<p>No, I think <code>panic!</code> is a macro because it accepts variable arguments, like <code>println!</code>, and the only way we currently have to do that is a macro.</p>



<a name="209200650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200650">(Sep 05 2020 at 23:42)</a>:</h4>
<p>Also, it does formatting, and a macro's the only way to check the format string at compile-time.  And it needs to call different traits depending on the format specifiers.</p>



<a name="209200666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Syntax%20Musing%3A%20%60try%20as%20Something%20%7B%20...%20%7D%60/near/209200666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Syntax.20Musing.3A.20.60try.20as.20Something.20.7B.20.2E.2E.2E.20.7D.60.html#209200666">(Sep 05 2020 at 23:43)</a>:</h4>
<p>But anyway, I'll see if I can come up with a demo of the overall idea of a different (set of) <code>Try</code> trait(s).</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>